package com.xiaoyu.izf.controller;

import com.xiaoyu.izf.aspect.RequestAuth;
import com.xiaoyu.izf.model.UserInfo;
import com.xiaoyu.izf.model.page.DataTableBean;
import com.xiaoyu.izf.model.page.ParamListBean;
import com.xiaoyu.izf.service.VipOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Controller
@RequestMapping("/vip/order")
public class VipOrderController extends BaseController {

    @Autowired
    private VipOrderService vipOrderService;

    @RequestMapping("/list_page")
    @RequestAuth
    public String listPage(){
        return "mgr/vip_order/vip_order_list";
    }

    @RequestMapping("/list")
    @ResponseBody
    @RequestAuth
    public DataTableBean list(HttpServletRequest request, @RequestBody String body) throws IOException {
        UserInfo user = user(request);
        ParamListBean paramListBean = getParamListBean(body);
        DataTableBean dataTableBean = vipOrderService.list(paramListBean,user);
        return dataTableBean;
    }

    /**
     * 合伙人or服务商vip订单列表页面
     * @return
     */
    @RequestMapping("/par_list_page")
    @RequestAuth
    public String parListPage(){
        return "mgr/vip_order/par_vip_order_list";
    }

    @RequestMapping("/par_list")
    @ResponseBody
    @RequestAuth
    public DataTableBean parList(HttpServletRequest request, @RequestBody String body) throws IOException {
        UserInfo user = user(request);
        ParamListBean paramListBean = getParamListBean(body);
        DataTableBean dataTableBean = vipOrderService.list(paramListBean,user);
        return dataTableBean;
    }
}
